package xyz.sunne.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @author Sunne
 * @version 1.0
 * @date 2021/9/24 0024
 */
public abstract class BaseService<M extends BaseMapper<T>,T> extends ServiceImpl<M,T> {
    public T getByKey(SFunction<T,?> key, String value){
        return this.getOne(new LambdaQueryWrapper<T>().eq(key,value));
    }

    public List<T> getListByKey(SFunction<T,?> key, String value){
        return this.list(new LambdaQueryWrapper<T>().eq(key,value));
    }
}
